package com.xiqin.security.util;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * @Author TaoQiansheng
 * @Date 2020-05-07 15:57
 * @Version 1.0
 */
public class CustomerPasswordEncoder extends BCryptPasswordEncoder {
    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        if (encodedPassword != null && encodedPassword.length() != 0) {
            if(DigestUtils.md5Hex(rawPassword.toString()).equals(encodedPassword.toString())) {
                return true;
            }else {
                return false;
            }
        }
        return super.matches(rawPassword,encodedPassword);
    }
}